package spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * User: wlai
 * Date: 3/17/15
 * Time: 15:55 PM
 */
@Configuration
public class Application {

    @Bean(name = "helloBean")
    public IBean getIBean() {
        IBean b = new MyBean();
        b.setName("Laiyubin");
        return b;
    }


    public static void main(String[] args) {
//        ApplicationContext context = new AnnotationConfigApplicationContext(Application.class);
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        IBean bean = (IBean) context.getBean("helloBean");
        bean.setName("laiyubin");
        bean.sayHello();//("Spring3 Java Config");
    }

}
